<template>
    <div>
        <el-form :inline="true" :model="data">
            <el-form-item
                v-for="item in formList"
                :label-width="'120px'"
                :key="item.label"
                :label="item.label"
                :style="item.style || 'width:340px;'"
            >
                <el-select v-if="item.type === 'select'" v-model="data[item.prop]" size="mini">
                    <el-option
                        v-for="item in item.options"
                        :key="item.label"
                        :label="item.label"
                        :value="item.value"
                    ></el-option>
                </el-select>
                <div v-else-if="item.type === 'text'">
                    <el-upload
                        :with-credentials="true"
                        class="upload-demo"
                        name="fileInput"
                        :file-list="uploadFileList"
                        :on-remove="
                            v =>
                                uploadFileList.splice(
                                    uploadFileList.findIndex(u => u.url == v.url),
                                    1
                                )
                        "
                        :on-preview="handlePreview"
                        :action="uploadHttp"
                        :on-success="uploadSuccess"
                        :show-file-list="true"
                        :before-upload="beforeUpload"
                        :headers="{ token: getToken() }"
                    >
                        <el-button size="small" type="primary">点击上传</el-button>
                    </el-upload>
                </div>
                <el-input v-else type="primary" size="small" v-model="data[item.prop]"></el-input>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import BudgetBaseInfo from './BudgetBaseInfo';
export default BudgetBaseInfo;
</script>

<style lang="less" scoped>
.upload-demo {
    width: 180px;
}
</style>
